package plantshop.model;
import java.io.Serializable;
import java.util.Random;

import plantshop.controller.moves.CreatureTurnMove;
import plantshop.controller.moves.CreatureWalkMove;
import plantshop.controller.moves.Move;


public class Creature implements Serializable{
	private static final long serialVersionUID = -8513378872293026898L;
	private int type;
	// 1 butterfly
	// 2 wildlife
	
	private Location location;
	
	
	private int dirX,dirY;
	
	public Creature(int type){
		this.setType(type);
		Random generator = new Random(); 
		
		location = new Location( generator.nextInt(200), generator.nextInt(400)+200);
		
		dirX = generator.nextInt(10)-5;
		dirY = generator.nextInt(10)-5;
	}
	
	public static Creature makeCreature(int type){
		
		return new Creature(type);
	}

	public Move getNextMove(){
		if(location.getX()<0 || location.getX()>200)
		{
			dirX=-dirX;
		}
		if(location.getY()<0 || location.getY()>600)
		{
			dirY=-dirY;
		}
		return new CreatureWalkMove(this,dirX,dirY);
	}
	
	
	public Move getNextTure(){
		Random generator = new Random(); 
		int x = generator.nextInt(10)-5;
		int y = generator.nextInt(10)-5;
		return new CreatureTurnMove(this,x,y);
	}
	
	public Location getLocation() {
		return location;
	}

	public void setLocation(Location location) {
		this.location = location;
	}
	
	public void setDir(int x, int y){
		this.dirX =x;
		this.dirY = y;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}
	
	public int getDirX()
	{
		return dirX;
	}
	
	public int getDirY()
	{
		return dirY;
	}
}
